Window Titles and Text (Advanced)

AutoIt operates in one of four "Window matching" modes.  The modes are set with the AutoItSetOption function using the WinTitleMatchMode option.

 

Mode 1 (default)

Matches partial titles from the start.

In this mode the a window titled Untitled - Notepad would be matched by "Untitled - Notepad", "Untitled", "Un", etc. 

eg.

    oAutoIt.WinWait "Untitled"

 

Mode 2

Matches any substring in the title.

In this mode a window titled Untitled - Notepad would be matched by "Untitled - Notepad", "Untitled", "Notepad", "pad", etc.

eg.

    oAutoIt.WinWait "Notepad"

 

Mode 3

Exact title match.

In this mode a window titled Untitled - Notepad would only be matched by "Untitled - Notepad"

 

Mode 4

Advanced mode.

In this mode special sequences are used in the title parameter so that window classnames and handles can be used.  The text parameter remains the same.

The special sequences must contain no whitespace.  They are:

    "classname=CLASSNAME"

    "handle=winhandle"

    "active"

    "last" or ""

 

"classname=" matches a window based on its classname.  For example to identify a window that has the classname "MYCLASS1" then you would use "classname=MYCLASS1" for the title parameter.


"active"
matches the currently active window (same as "" in the default WinTitleMatchMode).


"last" uses the last successful window match so you don't have to keep specifying the title and text again and again. e.g.

    oAutoIt.AutoItSetOption "WinTitleMatchMode", 4

    oAutoIt.WinWaitActive "Untitled - Notepad"

    oAutoIt.WinClose "last"     ' Closes the previously matched notepad window


Note: If "classname=", "handle=", "active", "last" or "" are not used as the title then the window matching takes place as in Mode 1 making this a good mode for general use.